<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE xsl:stylesheet SYSTEM "lang://system">

<xsl:stylesheet
	version="1.0"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	
	<xsl:output
		encoding="utf-8"
		indent="yes"
		doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
		omit-xml-declaration="yes"
		method="xml" />
		
	<xsl:include href="banners/show.xsl" />
	
	<xsl:param name="userGroup" select="/data/@user-group" />
	<xsl:param name="userId" select="/data/@user-id" />
	<xsl:param name="module" select="/data/@module" />
	<xsl:param name="method" select="/data/@method" />
	<xsl:param name="baseURI" select="/data/@base-uri" />
	<xsl:param name="pageTitle" select="/data/@title" />
	
	<!-- Meta-теги стрианицы -->
	<xsl:template name="meta-head">
		<link href="{$baseURI}/favicon.ico" type="image/ico" rel="icon" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		
		<script type="text/javascript">
		<xsl:text>var baseURI = "</xsl:text>
		<xsl:value-of select="$baseURI" />
		<xsl:text>";</xsl:text>
		</script>
		
		<script type="text/javascript" src="{$baseURI}/js/jQuery.js" />
		<script type="text/javascript" src="{$baseURI}/js/jQuery.corner.js" />
		<script type="text/javascript" src="{$baseURI}/js/messages.js" />
		<link rel="stylesheet" href="{$baseURI}/css/base.css" type="text/css" media="all" />
		<link rel="stylesheet" href="{$baseURI}/css/main.css" type="text/css" media="all" />
		
		<xsl:comment>[if IE]&gt;&lt;link rel="stylesheet" href="<xsl:value-of select="$baseURI"/>/css/main-ie.css" type="text/css" media="all" /&gt;&lt;![endif]</xsl:comment>
	</xsl:template>
	
	<!-- Userbar -->
	<xsl:template name="top-userbar">
		<div id="cms_messages" />

		<div id="user-bar">
			<div id="user-bar_inner">
				<xsl:choose>
					<xsl:when test="@user-group = 'guest'">
						<form action="{$baseURI}/users/login" method="post">
							&labelLogin;<xsl:text>: </xsl:text><input type="text" name="login" size="16" />
							<xsl:text> </xsl:text>
							&labelPassword;<xsl:text>: </xsl:text>
							<input type="password" name="password" size="16" />
							<xsl:text> </xsl:text><input type="submit" value="&labelToLogin;" />
							<xsl:text> </xsl:text><a href="{$baseURI}/users/registration/">&labelRegistration;</a>
						</form>
					</xsl:when>
					
					<xsl:otherwise>
						<xsl:apply-templates mode="user-bar" select="document(concat('xobject://user/', $userId))/data/object" />
					</xsl:otherwise>
				</xsl:choose>
			</div>
		</div>
	</xsl:template>
	
	<!-- Лого -->
	<xsl:template name="logo">
		<div id="logo">
			<a href="{$baseURI}/">
				<img src="{$baseURI}/images/logo.png" alt="" />
			</a>
		</div>
	</xsl:template>	
	
	
	<!-- Блоки по-умолчанию -->
	<xsl:template name="default-blocks-top">
		<xsl:apply-templates select="document('xmodule://banners/get/all;block')/data/response" mode="banners" />
	</xsl:template>
	<xsl:template name="default-blocks-bottom" />
	
	<!-- Footer -->
	<xsl:template name="footer">
		<div id="footer">
			<a href="{$baseURI}/page/about">&labelAboutSite;</a>
			<xsl:text> ∙ </xsl:text>
			<a href="{$baseURI}/page/contacts">&labelContacts;</a>
			<p>&labelWorkedOn; <a href="http://explay.su">Explay CMS</a> 3</p>
		</div>
	</xsl:template>
	
	<!-- Сообщение -->
	<xsl:template match="response/message">
		<div class="system_message"><xsl:value-of select="." /></div>
	</xsl:template>
	
	<!-- Сообщение об ошибке -->
	<xsl:template match="response/error">
		<div class="system_error"><xsl:value-of select="." /></div>
	</xsl:template>
	
	<!-- User Bar -->
	<xsl:template match="object[@type='user']" mode="user-bar">
		<xsl:param name="login" select="property[@name='login']/value" />
		<xsl:param name="avatar" select="property[@name='avatar']/value" />
		
		<div id="user-bar_avatar">
			<a href="{$baseURI}/user/{$login}">
				<xsl:if test="$avatar = ''">
					<img src="{$baseURI}/images/default-avatar.png" alt="" />
				</xsl:if>
				<xsl:if test="$avatar != ''">
					<img src="{$baseURI}/thumb_50_50{$avatar}" alt="" />
				</xsl:if>
			</a>
		</div>
		<div id="user-bar_options">
			<xsl:text>&labelBarHello;, </xsl:text>
			<a href="{$baseURI}/user/{$login}">
				<xsl:value-of select="property[@name='name']/value" />
			</a>
			<xsl:text>!</xsl:text>
			<br /><a href="{$baseURI}/users/logout" id="exit_button">&labelBarExit;</a>
		</div>
		<div id="user-bar_action">
			<div class="user-bar_action_button">
				<div class="l" />
				<div class="c_all add_post"><a href="{$baseURI}/blogs/add">&labelBarWrite;</a></div>
				<div class="r" />
			</div>
			<div class="user-bar_action_button">
				<div class="l" />
				<div class="c_all add_photo"><a href="{$baseURI}/photos/upload">&labelBarPhoto;</a></div>
				<div class="r" />
			</div>
			<div class="user-bar_action_button">
				<div class="l" />
				<div class="c_all go_messages"><a href="{$baseURI}/mail">&labelBarMessages; (<xsl:value-of select="document('xmodule://mail/getCountNewMessages')/data/response/count/value" />)</a></div>
				<div class="r" />
			</div>
			<div class="user-bar_action_button">
				<div class="l" />
				<div class="c_all settings"><a href="{$baseURI}/users/edit_profile">&labelBarSettings;</a></div>
				<div class="r" />
			</div>
			
			<xsl:if test="$userGroup = 'admin'">
				<div class="user-bar_action_button">
					<div class="l" />
					<div class="c_all admin"><a href="{$baseURI}/admin/system">&labelAdmin;</a></div>
					<div class="r" />
				</div>
			</xsl:if>
		</div>
	</xsl:template>

</xsl:stylesheet>